using System;
using System.Collections.Generic;
using System.Text;

namespace TuringMachine.StateAutomat
{

    public class State : IDisposable
    {
        #region Private members
        private String _name;
        private StateType _type;        
        
        #endregion

        #region Properties
        public StateType Type
        {
            get { return _type; }
            set { _type = value; }
        }
        public String Name
        {
            get { return _name; }
            set { _name = value; }
        }
        #endregion

        #region Constructors
        public State()
        {
            
            _name = string.Empty;
            _type = StateType.UnknownState;
        }
        public State(String name)
        {
            
            _name = name;
            _type = StateType.UnknownState;
        }
        public State(String name, StateType type)
        {
            
            _name = name;
            _type = type;
        }
        #endregion

        #region Public methods
        public Boolean IsStart()
        {
            return (_type == StateType.StartState);
        }
        public Boolean IsHalt()
        {
            return (_type == StateType.HaltState);
        }
        public Boolean IsYes()
        {
            return _type == StateType.YesState;
        }
        public Boolean IsNo()
        {
            return _type == StateType.NoState;
        }
        
        /*public State GetNextState(char inputChar)
        {
            if (transactionTable.ContainsKey(inputChar))
            {
                return transactionTable[inputChar];
            }
            else
            {
                return null;
            }
        }

        public Char GetTapeAction(char inputChar)
        {
            if (tapeActionTable.ContainsKey(inputChar))
            {
                return tapeActionTable[inputChar];
            }
            else
            {
                return null;
            }
        }
        public void AddTransition(char inputChar, State nextState)
        {
            if (transactionTable.ContainsKey(inputChar))
            {
                throw new Exception("Already exist transaction from state '" + this.Name + "' with character '" + inputChar + "'");
            }
            else
            {
                transactionTable.Add(inputChar, nextState);
            }
        }
        public void AddTapeAction(char inputChar, char tapeAction)
        {
            if (tapeActionTable.ContainsKey(inputChar))
            {
                throw new Exception("Already exist tape action for state '" + this.Name + "' with character '" + inputChar + "'");
            }
            else
            {
                tapeActionTable.Add(inputChar, tapeAction);
            }
        }        */
        #endregion

        #region IDispose method
        public void Dispose()
        {
            
        }
        #endregion
    }
    
}
